﻿using System;
using System.Data;
using System.Linq.Expressions;

namespace HF.Repository
{
    public interface IReadonlyRepository<T>
    {
        Boolean Exists(T model);
        Boolean Exists(T model, IDbTransaction transaction);

        T Get(Expression<Predicate<T>> where);

        T Get<TKey>(TKey key) where TKey : IEquatable<TKey>;
        T Get<TKey>(TKey key, IDbTransaction transaction) where TKey : IEquatable<TKey>;


        int Count();
        int Count(Expression<Predicate<T>> where);
        int Count(Expression<Predicate<T>> where, IDbTransaction transaction);

        PagedList<T> Select(int index, int pageSize);
        PagedList<T> Select(int index, int pageSize, Expression<Predicate<T>> where);

        PagedList<T> Select<TKey>(int index, int pageSize, Expression<Predicate<T>> where,
                                  Expression<Func<T, TKey>> order);

        PagedList<T> Select<TKey>(int index, int pageSize, Expression<Predicate<T>> where,
                                  Expression<Func<T, TKey>> order, bool asc);
    }
}